package com.example.travelapplication.dao;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import com.example.travelapplication.entity.Attraction;

import java.util.List;

@Dao
public interface AttDao {
    @Query("SELECT * FROM att")
    List<Attraction> getAllAtt();

    @Query("SELECT * FROM att where category = :category")
    List<Attraction> getAttByCategory(int category);

    @Query("SELECT * FROM att WHERE title LIKE '%' || :search || '%' OR location LIKE '%' || :search || '%'")
    List<Attraction> getAttBySearch(String search);

    @Query("SELECT * FROM att where attId = :attId")
    Attraction getAttById(int attId);

    @Query("DELETE FROM att")
    void deleteAll();

    @Insert
    void add(Attraction attraction);

    @Delete
    void delete(Attraction attraction);

    @Update
    void update(Attraction attraction);

}
